package fun.tan90.easy.binlog.manager.handler;

import cn.hutool.json.JSONUtil;
import fun.tan90.easy.binlog.base.constants.EasyBinlogConstants;
import fun.tan90.easy.binlog.base.strategy.AbstractExecuteStrategy;
import fun.tan90.easy.binlog.manager.property.EasyBinlogManagerProperties;
import lombok.extern.slf4j.Slf4j;
import org.noear.socketd.transport.core.Entity;
import org.noear.socketd.transport.core.entity.StringEntity;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * description TODO
 * company 铁人科技
 *
 * @author 陈浩杰
 * @date 2023/12/15 19:42
 */
@Slf4j
@Component
public class WorkerConfigGetHandler implements AbstractExecuteStrategy<String, Entity> {

    @Resource
    EasyBinlogManagerProperties easyBinlogManagerProperties;

    @Override
    public String mark() {
        return EasyBinlogConstants.WORKER_CONFIG_GET;
    }

    @Override
    public Entity executeResp(String params) {
        return new StringEntity(JSONUtil.toJsonStr(easyBinlogManagerProperties.getWorkerConfig()));
    }
}
